<template>
    <div>
        <div>
        <p>
            <button v-for="i in cates" :key="i.id" @click="sub(i.id,i.name)">{{i.name}}</button>
        </p>
        </div>
        <h2>{{str}} 电脑分类</h2>
         <ul >
            <li v-for="i in items" :key="i.id">{{i.name}}</li>
        </ul>   
    </div>    
</template>

<script>
import axios from "axios"
import {get_cateC} from "../axios_api/api.js"
export default {
    name:"showcate",
    data() {
        return {
            cates:"",
            items:"",
            str:"",
        }
    },
    methods:{
         get_cate(){
            get_cateC().then(res=>{
                console.log(res)
                this.cates = res.data
            })
        },
        sub(id,name){
            var data={"id":id
                }
            axios({
                url:"http://127.0.0.1:8000/app02/cc/",
                method:"get",
                params:data
            }).then(res=>{
                console.log(res.data)
                this.items = res.data.data
                this.str = name
            })
        },

    },
    created(){
        this.get_cate()
    }

}
</script>

<style>

</style>



